package someTestExcemple.innerClassTest;

public class innerClassTest2 {
    public static void main(String[] args) {
        //匿名内部类的常见使用场景
        Swimming s1 = new Swimming() {
            @Override
            public void swim() {
                System.out.println("狗游泳飞快---");
            }
        };
        go(s1);
        //匿名内部类作为参数传递给方法  ---匿名内部类的最终核心目的就是为了简化代码
        go(new Swimming() {
            @Override
            public void swim() {
                System.out.println("猫游泳一般般---");
            }
        });
        //lambda表达式进一步简化
        go(()->{
            System.out.println("fish swimming---");
        });
    }
    public static void go(Swimming swimming) {
        System.out.println("go go go--参加游泳比赛---");
        swimming.swim();
    }
}
interface Swimming{
    void swim();
}